package com.weu.mapper;

import com.weu.bean.Comment;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CommentMapper {

    /**
     * 查询所有的评论
     *
     * @return
     */
    @Select("select * from ilmc_comment")
    public List<Comment> getAllComments();

    /**
     * 查询指定博客的所有评论信息
     *
     * @return
     */
    @Select("SELECT * from ilmc_comment,ilmc_blog WHERE comment_bid=blog_id and blog_id=#{id} ")
    public List<Comment> getComments(int blogid);

    /**
     * 添加评论
     *
     * @param comment
     * @return
     */
    @Insert("insert into ilmc_comment(comment_uid, comment_bid, comment_content, comment_createtime) values(#{commentUid}, #{commentBid},#{commentContent},SYSDATE())")
    public int insertComment(Comment comment);

    /**
     * 根据博客ID删除指定博客
     *
     * @param id
     * @return
     */
    @Delete("delete from ilmc_comment where comment_id=#{id}")
    public int delCommentById(int id);
}
